/*
 * Copyright (c) 2017, Iotelligent Corporation
 * All rights reserved.
 *
 * Description:
 *
 *   ibat2000_types.h contains Iotelligent-defined data types:
 *   - Inherit the data types defined in ARM Clib
 *   - Macro definitions which are used for bit-operations
 */

#ifndef __IOT_HW_TYPES_H__
#define __IOT_HW_TYPES_H__

#include <stdint.h>

#ifndef NULL
    #define NULL    ((void *)0)
#endif

/* Bitwise operation macro */
#ifndef BIT
    #define BIT(x)  (1U << (x))
#endif

/* Bit offset definition */
#define BIT_0           ((uint32_t)1 << 0 )
#define BIT_1           ((uint32_t)1 << 1 )
#define BIT_2           ((uint32_t)1 << 2 )
#define BIT_3           ((uint32_t)1 << 3 )
#define BIT_4           ((uint32_t)1 << 4 )
#define BIT_5           ((uint32_t)1 << 5 )
#define BIT_6           ((uint32_t)1 << 6 )
#define BIT_7           ((uint32_t)1 << 7 )
#define BIT_8           ((uint32_t)1 << 8 )
#define BIT_9           ((uint32_t)1 << 9 )
#define BIT_10          ((uint32_t)1 << 10)
#define BIT_11          ((uint32_t)1 << 11)
#define BIT_12          ((uint32_t)1 << 12)
#define BIT_13          ((uint32_t)1 << 13)
#define BIT_14          ((uint32_t)1 << 14)
#define BIT_15          ((uint32_t)1 << 15)
#define BIT_16          ((uint32_t)1 << 16)
#define BIT_17          ((uint32_t)1 << 17)
#define BIT_18          ((uint32_t)1 << 18)
#define BIT_19          ((uint32_t)1 << 19)
#define BIT_20          ((uint32_t)1 << 20)
#define BIT_21          ((uint32_t)1 << 21)
#define BIT_22          ((uint32_t)1 << 22)
#define BIT_23          ((uint32_t)1 << 23)
#define BIT_24          ((uint32_t)1 << 24)
#define BIT_25          ((uint32_t)1 << 25)
#define BIT_26          ((uint32_t)1 << 26)
#define BIT_27          ((uint32_t)1 << 27)
#define BIT_28          ((uint32_t)1 << 28)
#define BIT_29          ((uint32_t)1 << 29)
#define BIT_30          ((uint32_t)1 << 30)
#define BIT_31          ((uint32_t)1 << 31)

/* Data types definition */
typedef unsigned char  u8;
typedef signed char    s8;
typedef unsigned short u16;
typedef signed short   s16;
typedef unsigned int   u32;
typedef signed int     s32;

/*
 * The type-defined prototype of function pointer
 * for peripheral ISR handler.
 *
 * - p
 *   The void type pointer can be casted to any type
 *   of peripheral(UART/TIMER) type pointer.
 */
typedef void ( *FUN_INT_CALLBACK_T )( void *p );

/* Bool type enumerations */
enum
{
    IOT_DISABLE = 0,
    IOT_ENABLE,

    IOT_INVALID = 0,
    IOT_VALID,

    IOT_OFF = 0,
    IOT_ON,

    IOT_LOW = 0,
    IOT_HIGH,

    IOT_CLOSE = 0,
    IOT_OPEN,

    IOT_START = 0,
    IOT_FINISH,

    IOT_RESET = 0,
    IOT_SET,

    IOT_ASSERT = 0,
    IOT_DEASSERT
};

#endif /* __IBAT2000_TYPES_H__ */
